// 模版字符串

{
  function fun(string, name) {
    console.log(string, name);
    return string[0] + name;
  }

  const name = "lx";
  const str = fun`hello，${name}`;
  console.log(str);
}

// Object.is()
{
  console.log(Object.is(NaN, NaN));
  console.log(Object.is(+0, -0));
}

// proxy
{
  const person = {
    name: "lx",
    age: 12,
  };

  console.log("name" in person);

  const personProxy = new Proxy(person, {
    get(target, p, receiver) {
      return target[p];
    },
    set(target, p, value, receiver) {
      target[p] = value;
    },
  });
  console.log(personProxy.name);

  personProxy.sex = "男";
  console.log(personProxy);

  const list = [];

  const listProxy = new Proxy(list, {
    set(target, p, value, receiver) {
      // console.log(target, p, value);
      target[p] = value;
      return true;
    },
  });

  listProxy.push(2);
  listProxy.push(3);
  listProxy.push(4);
  listProxy.push(5);
  listProxy.push(6);
  listProxy.splice(0, 1);
}

//set
{
  const set = new Set();
  set.add(1).add(2);
  set.delete(1);
  set.clear();
  console.log(set.has(2));
  console.log(set);
}

//map
{
  const map = new Map();
  map.set("name", "xx");
  console.log(map.get("name"));
}

//symbol
{
  const symbol = Symbol();

  const obj = {
    [symbol]: "1",
  };

  console.log(obj[symbol]);
  console.log(Symbol() === Symbol());
}
